/*
 * Package il.ac.biu.cs.grossmm.impl.simple
 * File SipSubscriptionImpl.java
 * 
 * This is a part of presence service framework prototype. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package il.ac.biu.cs.grossmm.impl.simple;

import il.ac.biu.cs.grossmm.api.simple.InternalSubscription;
import il.ac.biu.cs.grossmm.api.simple.SipEventPackage;
import il.ac.biu.cs.grossmm.api.simple.SipSubscription;
import il.ac.biu.cs.grossmm.api.simple.SubscriptionEvent;
import il.ac.biu.cs.grossmm.api.simple.SubscriptionState;

import javax.sip.Dialog;

import org.apache.log4j.Logger;

class SipSubscriptionImpl implements SipSubscription {
	
	/**
	 * Logger for this class
	 */
	private final Logger logger = Logger.getLogger(SipSubscriptionImpl.class);
	
	final SipEventPackage eventPackage;
	final String id;
	
	Dialog dialog;
	InternalSubscription internal;
	Object param;
	
	
	SubscriptionState state;
	SubscriptionEvent event;
	String reason;
	int retryAfter;
	long timeoutTime;
	

	boolean isOpen = true;

	
	public SipSubscriptionImpl(SipEventPackage eventPackage, String id) {
		this.eventPackage = eventPackage;
		this.id = id;
		
		state = SubscriptionState.INIT;
	}

	public Dialog getDialog() {
		return dialog;
	}
	
	public void setDialog(Dialog dialog) {
		this.dialog = dialog;
	}

	public String getId() {
		return id;
	}

	public SipEventPackage getEventPackage() {
		return eventPackage;
	}


	public SubscriptionEvent getEvent() {
		return event;
	}

	public String getReason() {
		return reason;
	}

	public int getRetryAfter() {
		return retryAfter;
	}

	public SubscriptionState getState() {
		return state;
	}

	public long getTimeoutTime() {
		return timeoutTime;
	}

	public Object getParam() {
		return param;
	}

	public void setState(SubscriptionEvent event, SubscriptionState state, String reason) {
		this.event = event;
		this.state = state;
		this.reason = reason;
	}

	public InternalSubscription getInternalSubscription() {
		return internal;
	}

	public void setInternalSubscription(InternalSubscription internal) {
		this.internal = internal;
	}

	public void setParam(Object param) {
		this.param = param;
	}
}